nv.http.Flash = function (url, method) {
    nv.util.OOP.extend(this, nv.http.Base, url, method);
    if (/^\/\//.test(url)) {
        url = document.location.protocol + url;
    }
    var $this = this;
    $this.Timeout = 14000;
    var SwfUri = nv.Urls.ServerUrl + "/common/resources/swf/httpProxy.swf";
    var flashId = "Wikinvest_Flash_Http_Proxy_Flash";
    var containerId = "Wikinvest_Flash_Http_Proxy_Container";
    var getFlash = function () {
        return document.getElementById(flashId);
    };
    var checkFlash = function () {
        try {
            if (typeof getFlash().ping === "undefined") {
                return false;
            }
            return (getFlash().ping() == "pong");
        } catch (e) {
            return false;
        }
    };
    var Setup = function () {
        if (!nv.Swfobject.hasFlashPlayerVersion('8.0.0')) {
            return false;
        }
        if (document.getElementById(containerId) !== null) {
            return true;
        }
        var params = {
            allowScriptAccess: "always",
            swliveconnect: true
        };
        var attributes = {
            id: flashId,
            name: flashId,
            data: SwfUri,
            width: 1,
            height: 1
        };
        var div = document.createElement("div");
        div.id = containerId;
        document.body.appendChild(div);
        var divToReplace = document.createElement("div");
        divToReplace.id = flashId;
        div.appendChild(divToReplace);
        nv.Swfobject.createSWF(attributes, params, flashId);
        return true;
    };
    $this._Send = function (params) {
        if (Setup() === false) {
            $this.TriggerFailure("no-flash-player");
            return;
        }
        var onReady = function () {
            var timeoutTimer = null;
            var unique_callback_name = $this.WrapCallbackAsGlobal(function (data) {
                window[unique_callback_name] = function (data) {};
                clearTimeout(timeoutTimer);
                if (typeof (data) == "undefined") {
                    $this.TriggerFailure("httperror");
                } else {
                    $this.TriggerSuccess(data);
                }
            });
            timeoutTimer = setTimeout(function () {
                window[unique_callback_name] = function (data) {};
                $this.TriggerFailure("timeout");
            }, $this.Timeout);
            var fs = getFlash();
            var data = $this.GetQueryString(params);
            fs.xmlhttp(url, unique_callback_name, method, data);
        };
        if (!checkFlash()) {
            var setupTimeoutTimer = null;
            var setupCheckTimer = null;
            setupTimeoutTimer = setTimeout(function () {
                if (setupCheckTimer !== null) {
                    clearTimeout(setupCheckTimer);
                }
                $this.TriggerFailure("interface-failure");
            }, 7000);
            var timerEvent = function () {
                if (checkFlash()) {
                    clearTimeout(setupTimeoutTimer);
                    onReady();
                } else {
                    setupCheckTimer = setTimeout(timerEvent, 500);
                }
            };
            timerEvent();
        } else {
            onReady();
        }
    };
};